#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

string s1, s2;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> s1 >> s2;

    for(int i = 0; i < s1.size() && i < s2.size(); i ++){
        if(s1[i] != s2[i]){
            cout << i + 1 << '\n';
            return 0;
        }
    }

    cout << s2.size() << '\n';


    return 0;
}